<template>

    <view>
        <daya-clone-navbar :prop_clone_navbar="clone_navbar" :prop_is_ipx="is_ipx"/>

      <view class="main">
        <view class="zjgg" style="padding-top: 20rpx" v-if="dblb.length > 0">
          <view class="zjgg-swiper">
            <swiper
              autoplay="auto"
              :circular="true"
              class="swiper"
              duration="500"
              indicatorActiveColor="#34AAFF"
              indicatorColor="white"
              :indicatorDots="dblb.length > 1"
              interval="5000"
            >
              <swiper-item
                :data-index="index"
                v-for="(item, index) in dblb"
                :key="item.unique"
              >
                <image
                  @tap="jumps"
                  class="img"
                  :data-appid="item.appid"
                  :data-id="item.id"
                  :data-name="item.title"
                  :data-src="item.src"
                  :data-type="item.item"
                  :data-wb_src="item.src2"
                  :src="item.logo"
                ></image>
              </swiper-item>
            </swiper>
          </view>
        </view>
        <ad :unitId="item.src" v-for="(item, index) in zbllz" :key="index"></ad>
        <view class="tjsj" v-if="mdxx.is_tj == '1'">
          <!-- <view class="jzwb">
            <view class="hx"></view>
            <view class="wz tbwz">推荐商家</view>
            <view class="hx"></view>
          </view> -->
          <!-- parse <template is="sort_list" :data="selected:selected,sortSelected:sortSelected,issx:issx,mask1Hidden:mask1Hidden"></template> -->
          <block name="sort_list">
            <view class="sort-list">
              <view
                @tap="onOverallTag"
                :class="'sort ' + (selected == 0 ? '' : 'sort-active')"
              >
                <view>{{ sortSelectedFun || '综合排序' }}</view>
                <image
                  :class="mask1Hidden ? 'sortimg' : 'sortimg1'"
                  src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/down1.png"
                ></image>
              </view>
              <view
                @tap="onTapTag"
                :class="'sort ' + (selected == 1 ? 'sort-active' : '')"
                data-index="1"
                >距离最近</view
              >
              <view
                @tap="onTapTag"
                :class="'sort ' + (selected == 2 ? 'sort-active' : '')"
                data-index="2"
                >好评优先</view
              >
              <view
                @tap="onFilter"
                :class="'sort ' + (issx ? 'sort-active' : '')"
              >
                <view>筛选</view>
                <image
                  class="sortimg"
                  src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/screen.png"
                ></image>
              </view>
            </view>
          </block>

          <view
            @tap="mask1Cancel"
            :class="'mask1 ' + (mask1Hidden ? '' : 'maskactive')"
            :style="{ display: mask1Hidden ? 'none' : 'block' }"
          >
            <view class="maskbody">
              <!-- parse <template is="sort_list" :data="selected:selected,sortSelected:sortSelected,issx:issx,mask1Hidden:mask1Hidden"></template> -->
              <view class="overall-sort-list">
                <view
                  @click="onSortSelectedFun"
                  class="overall-sort"
                  data-index="0"
                  :data-sortindex="index"
                  v-for="(item, index) in sortList"
                  :key="index"
                  >{{ item.sort }}</view
                >
              </view>
            </view>
          </view>
          <view
            @tap="mask2Cancel"
            :class="'mask ' + (mask2Hidden ? '' : 'maskactive')"
            :style="{ display: mask2Hidden ? 'none' : 'block' }"
          >
            <view class="maskbody">
              <!-- parse <template is="sort_list" :data="selected:selected,sortSelected:sortSelected,issx:issx,mask1Hidden:mask1Hidden"></template> -->
              <!-- <block name="sort_list">
                <view class="sort-list">
                  <view
                    @tap="onOverallTag"
                    :class="'sort ' + (selected == 0 ? 'sort-active' : '')"
                  >
                    <view>{{ sortSelectedFun }}</view>
                    <image
                      :class="mask1Hidden ? 'sortimg' : 'sortimg1'"
                      src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/down1.png"
                    ></image>
                  </view>
                  <view
                    @tap="onTapTag"
                    :class="'sort ' + (selected == 1 ? 'sort-active' : '')"
                    data-index="1"
                    >距离最近</view
                  >
                  <view
                    @tap="onTapTag"
                    :class="'sort ' + (selected == 2 ? 'sort-active' : '')"
                    data-index="2"
                    >好评优先</view
                  >
                  <view
                    @tap="onFilter"
                    :class="'sort ' + (issx ? 'sort-active' : 'sort-active2')"
                  >
                    <view>筛选</view>
                    <image
                      class="sortimg"
                      src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/screen.png"
                    ></image>
                  </view>
                </view>
              </block> -->
              <scroll-view class="filterList" :scrollY="true">
                <view class="filterList-characteristic-title"
                  >商家特色(多选)</view
                >
                <view class="filterList-characteristic-items">
                  <view
                    @tap.stop.prevent="characteristicSelectedFun"
                    :class="
                      'filterList-characteristic-item ' +
                      (characteristicSelected[index] == true
                        ? 'characteristic-selected'
                        : '')
                    "
                    :data-index="index"
                    :data-name="item.text"
                    v-for="(item, index) in characteristicList"
                    :key="index"
                  >
                    {{ item.text }}
                  </view>
                </view>
                <view class="filterList-discount-title">优惠活动(单选)</view>
                <view class="filterList-discount-items">
                  <view
                    @tap.stop.prevent="discountSelectedFun"
                    :class="
                      'filterList-discount-item ' +
                      (discountSelected == index ? 'discount-selected' : '')
                    "
                    :data-index="index"
                    v-for="(item, index) in discountList"
                    :key="index"
                  >
                    <text
                      class="filterList-discount-item-icon"
                      :style="'background:' + item.iconColor"
                      >{{ item.icon }}</text
                    >

                    {{ item.text }}
                  </view>
                </view>
              </scroll-view>
              <view class="filterList-footer">
                <view
                  @tap.stop.prevent="clearSelectedNumb"
                  class="filterList-footer-delect"
                  >清除筛选</view
                >
                <view
                  @tap="finish"
                  class="filterList-footer-finish"
                  v-if="selectedNumb != 0"
                >
                  完成
                  <view
                    class="filterList-footer-finish-number"
                    v-if="selectedNumb != 0"
                    >{{ selectedNumb }}</view
                  >
                </view>
                <view
                  class="filterList-footer-finish"
                  style="background: #efeff4"
                  v-else
                  >完成</view
                >
              </view>
            </view>
          </view>
          <view
            @tap="tzsjxq"
            :class="
              'sjlb flex-row ' +
              (item.is_yy == 2 && mdxx.isyykg == 1 ? 'bszz' : '')
            "
            :data-sjid="item.id"
            v-if="item.aa1 != NaN"
            v-for="(item, index) in storelist"
            :key="index"
          >
            <view class="sjleft flex-grow-0">
              <image
                class="sjleftimg"
                mode="aspectFill"
                :src="item.logo"
              ></image>
              <view class="xzhiding" v-if="item.is_brand == '1'">品牌</view>
            </view>

            <view class="sjright flex-grow-1 flex-col">
              <view class="sjright1 flex-bet flex-y-center">
                <view class="sjright1-l gobyndsingle">{{ item.name }}</view>
                <view class="isyy" v-if="item.is_yy == 2 && mdxx.isyykg == 1"
                  >休息中</view
                >
              </view>
              <view class="sjright2 flex-bet flex-y-center">
                <view class="flex-row flex-grow-1 flex-y-center">
                  <!-- <view class="pingjia_fenshu3">
                    <view class="kximg">
                      <image src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/i-star.png"></image>
                    </view>
                    <view
                      class="sximg"
                      :style="'width: ' + item.sales * 20 + '%'"
                    >
                      <image
                        src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/i-stars.png"
                      ></image>
                    </view>
                  </view> -->
                  <view class="pingfen">{{ item.sales }}</view>
                  <view class="recommed_midel">月售{{ item.score }}单</view>
                </view>
                <view
                  class="sjright2-r flex-grow-0 flex-row flex-y-center"
                  v-if="item.is_ps == '1'"
                >
                  <view class="sjright2-r1">{{ item.ps_mode }}</view>
                  <view class="sjright2-r2">准时达</view>
                </view>
              </view>
              <view class="sjright3 flex-bet flex-y-center">
                <view class="flex-row flex-y-center">
                  <view
                    class="sjright3text"
                    style="padding-left: 0"
                    v-if="item.is_ps == '1'"
                    >起送￥{{ item.start_at }}</view
                  >
                  <view
                    class="sjright3text"
                    style="border-right: 0"
                    v-if="item.is_ps == '1'"
                    >配送￥{{ item.ps_money }}起</view
                  >
                  <view
                    class="sjright3text"
                    style="border-right: 0"
                    v-if="item.is_ps != '1'"
                    >人均￥{{ item.capita }}/人</view
                  >
                </view>
                <view class="flex-row flex-y-center">
                  <view
                    class="sjright3text"
                    :style="'border-right:' + (item.is_ps == '1' ? '' : 0)"
                    v-if="item.is_ps != '1'"
                    >离你{{ item.aa }}</view
                  >
                  <view class="sjright3text" v-if="item.is_ps == '1'">{{
                    item.aa
                  }}</view>
                  <view
                    class="sjright3text"
                    style="border-right: 0; padding-right: 0"
                    v-if="item.is_ps == '1'"
                    >{{ item.ps_time }}</view
                  >
                </view>
              </view>
              <view
                class="sjright4"
                v-if="item.mj.length > 0 && item.xyh_open == '1'"
              >
                <view class="sjright4-l flex-grow-1" v-if="item.mj.length > 0">
                  <view class="flex-row">
                    <view class="mj">减</view>
                    <view class="gobyndsingle">
                      <text v-for="(i, index1) in item.mj" :key="index1"
                        >满{{ i.full }}减{{ i.reduction }},</text
                      >
                    </view>
                  </view>
                  <view class="flex-row" v-if="item.xyh_open == '1'">
                    <view class="xyh">新</view>
                    <view class="gobyndsingle"
                      >新用户下单立减{{ item.xyh_money }}元</view
                    >
                  </view>
                </view>
                <view class="sjright4-r flex-grow-0">
                  <image
                    :class="'sjright4-rimg ' + (item.open ? 'show' : 'close')"
                    src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/down.png"
                  ></image>
                </view>
              </view>
            </view>
          </view>
          <view class="jzz" v-if="!mygd">
            <image
              class="Rotation"
              src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/jzz.png"
            ></image>
            <view>加载中...</view>
          </view>
          <view class="kong" v-if="storelist.length == 0 && mygd">
            <image src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/wushuju.png"></image>
            <view>暂无相关数据</view>
          </view>
          <view class="jzwb" v-if="mygd">
            <view class="hx"></view>
            <view class="wz">加载完毕</view>
            <view class="hx"></view>
          </view>
        </view>
        <view class="copyright">
          <navigator
            :appId="mdxx.tz_appid"
            class="copyright_logo"
            extraData=""
            openType="navigate"
            path=""
            target="miniProgram"
            version="release"
          >
            <image
              class="copyright_img"
              mode="aspectFill"
              :src="mdxx.bq_logo"
            ></image>
            <view class="copyright_text">{{ mdxx.bq_name }}</view>
          </navigator>
          <view class="copyright_txt">{{ mdxx.support }}</view>
        </view>
      </view>
      <button @tap="hddb" class="hddb">
        <image src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/zd.png"></image>
      </button>
      <view class="fixed" v-if="istjhb">
        <view class="ab"></view>
        <view class="ab udlr animation">
          <view class="rel">
            <image
              :animation="animationData"
              class="img1"
              mode="aspectFit"
              src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/animation/tianjiang.png"
            ></image>
            <image
              :animation="animationData_2"
              class="img2 ab"
              mode="widthFix"
              src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/animation/img2.png"
            ></image>
            <image
              :animation="animationData_4"
              class="img4 ab"
              mode="widthFix"
              src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/animation/bag1.png"
            ></image>
            <image
              :animation="animationData_5"
              class="img5 ab"
              mode="widthFix"
              src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/animation/bag2.png"
            ></image>
          </view>
          <view :animation="animationData_1" class="rel">
            <view class="coupon ab">
              <view
                class="tjhbyhq"
                v-for="(item, index) in tjhbarr"
                :key="index"
              >
                <view class="tjhbyhqtop flex-row">
                  <view class="flex-grow-1">￥{{ item.reduce }}</view>
                  <view class="flex-grow-0">{{ item.name }}</view>
                </view>

                <view class="tjhbyhqft flex-row">
                  <view class="hyuan1"></view>
                  <view class="hyuan2"></view>
                  <view class="flex-grow-1">满{{ item.full }}可用</view>
                  <view class="flex-grow-0">有效期{{ item.end_time }}</view>
                </view>
              </view>
            </view>
            <view
              :animation="animationData_9"
              @tap="qxd"
              class="place_coupon ab"
            >
              <image
                mode="widthFix"
                src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/animation/place.png"
              ></image>
            </view>
            <image
              class="img1"
              mode="widthFix"
              src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/animation/back.png"
            ></image>
            <image
              :animation="animationData_6"
              class="img6 ab"
              mode="widthFix"
              src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/animation/img3.png"
            ></image>
            <image
              :animation="animationData_7"
              class="img7 ab"
              mode="widthFix"
              src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/animation/img1.png"
            ></image>
            <image
              :animation="animationData_8"
              class="img8 ab"
              mode="widthFix"
              src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/animation/img5.png"
            ></image>
          </view>
        </view>
      </view>
      <gettel
        v-if="userinfo && !userinfo.user_tel && mdxx.is_tel == 1"
      ></gettel>
    </view>

</template>

<script>
import cardlist from '@/ymq_canyino2o/dist/cardlist/index'
import gettel from '@/ymq_canyino2o/dist/gettel/index'

var qqmapsdk
var _typeof =
  'function' == typeof Symbol && 'symbol' == typeof Symbol.iterator
    ? function (t) {
        return typeof t
      }
    : function (t) {
        return t &&
          'function' == typeof Symbol &&
          t.constructor === Symbol &&
          t !== Symbol.prototype
          ? 'symbol'
          : typeof t
      }
var app = getApp()
var util = require('../../utils/util.js')
var QQMapWX = require('../../utils/qqmap-wx-jssdk.js')
export default {
  components: {
    cardlist,
    gettel
  },
  data() {
    return {
      curIndex: 0,
      nav: [
        {
          id: 0,
          label: '服务类'
        },
        {
          id: 1,
          label: '餐饮类'
        },
        {
          id: 2,
          label: '商品类'
        }
      ],
      characteristicList: [
        {
          text: '0配送费'
        },
        {
          text: '0元起送'
        }
      ],

      sortList: [
        {
          sort: '综合排序',
          image: ''
        },
        {
          sort: '销量最高',
          image: ''
        },
        {
          sort: '起送价最低',
          image: ''
        },
        {
          sort: '配送费最低',
          image: ''
        }
      ],

      discountList: [
        {
          icon: '减',
          iconColor: '#FF635B',
          text: '满减优惠',
          zdname: ' and d.money is not null'
        },
        {
          icon: '新',
          iconColor: '#34aaff',
          text: '新用户立减',
          zdname: ' and c.xyh_open=1'
        },
        {
          icon: '提',
          iconColor: '#6FDF64',
          text: '到店自提',
          zdname: ' and c.is_zt=1'
        }
      ],

      categoryList: {
        pageone: [
          {
            name: '美食',
            src: '/static/pages/images/1.png'
          },
          {
            name: '甜点饮品',
            src: '/static/pages/images/2.png'
          },
          {
            name: '美团超市',
            src: '/static/pages/images/3.png'
          },
          {
            name: '正餐精选',
            src: '/static/pages/images/4.png'
          },
          {
            name: '生鲜果蔬',
            src: '/static/pages/images/5.png'
          },
          {
            name: '全部商家',
            src: '/static/pages/images/6.png'
          },
          {
            name: '免配送费',
            src: '/static/pages/images/7.png'
          },
          {
            name: '新商家',
            src: '/static/pages/images/8.png'
          }
        ],
        pagetwo: [
          {
            name: '美食',
            src: '/static/pages/images/1.png'
          },
          {
            name: '甜点饮品',
            src: '/static/pages/images/2.png'
          },
          {
            name: '美团超市',
            src: '/static/pages/images/3.png'
          },
          {
            name: '正餐精选',
            src: '/static/pages/images/4.png'
          },
          {
            name: '生鲜果蔬',
            src: '/static/pages/images/5.png'
          },
          {
            name: '全部商家',
            src: '/static/pages/images/6.png'
          },
          {
            name: '免配送费',
            src: '/static/pages/images/7.png'
          },
          {
            name: '新商家',
            src: '/static/pages/images/8.png'
          }
        ]
      },

      params: {
        nopsf: 2,
        nostart: 2,
        yhhd: '',
        class_id:0,
      },

      issx: false,
      selected: 0,
      mask1Hidden: true,
      mask2Hidden: true,
      animationData: '',
      location: '',
      characteristicSelected: [false, false],
      discountSelected: null,
      selectedNumb: 0,
      sortSelected: '综合排序',
      pagenum: 1,
      storelist: [],
      bfstorelist: [],
      mygd: false,
      jzgd: true,
      isjzz: true,
      topmove: false,
      isxlsxz: false,

      userinfo: {
        user_tel: ''
      },

      CouponSet: '',
      istjhb: false,
      tjhbarr: '',

      mdxx: {
        typeset: '',
        fl_more: '',
        is_zb: '',
        qggn: '',
        is_qg: '',
        is_brand: '',
        is_tj: '',
        isyykg: 0,
        tz_appid: '',
        bq_logo: '',
        bq_name: '',
        support: '',
        is_tel: 0
      },

      navs: '',
      dbllz: '',
      zbllz: '',
      ZbOrder: '',
      qglist: '',
      toplb: '',
      zblb: '',
      dblb: '',

      cardlist: {
        pictureList: []
      },

      animationData_4: '',
      animationData_5: '',
      animationData_1: '',
      animationData_2: '',
      animationData_6: '',
      animationData_7: '',
      animationData_8: '',
      animationData_9: '',
      Brand: '',
      weizhi: '',
      startjwd: '',


      color: '',
      NaN: '',

      i: {
        full: '',
        reduction: ''
      },

      sortSelectedFun: ''
    }
  },
  onLoad: function (options) {
    if(options.class_id && options.class_id>0){
      this.params.class_id=options.class_id
    }

    this.onLoadClone3389(options)
  },
  onPageScroll: function (t) {
    if (0 < t.scrollTop) {
      this.setData({
        topmove: true
      })
    } else {
      this.setData({
        topmove: false
      })
    }
  },
  onReady: function () {},
  onShow: function () {},
  onHide: function () {},
  onUnload: function () {},
  onPullDownRefresh: function () {
    this.setData({
      issx: false,
      selected: 0,
      mask1Hidden: true,
      mask2Hidden: true,
      animationData: '',
      location: '',
      characteristicSelected: [false, false],
      discountSelected: null,
      selectedNumb: 0,
      sortSelected: '综合排序',
      params: {
        nopsf: 2,
        nostart: 2,
        yhhd: ''
      },
      pagenum: 1,
      storelist: [],
      bfstorelist: [],
      mygd: false,
      jzgd: true
    })
    console.log('下拉刷新', this.pagenum, this.isxlsxz)
    this.isxlsxz ||
      (this.setData({
        jzgd: false
      }),
      this.onLoadClone3389({}))
    uni.stopPullDownRefresh()
  },
  onReachBottom: function () {
    console.log('上拉加载', this.pagenum)
    this.mygd ||
      !this.jzgd ||
      this.isjzz ||
      (this.setData({
        jzgd: false
      }),
      this.getstorelist())
  },
  onShareAppMessage: function () {
    return {
      title: '' == this.mdxx.fx_title ? this.mdxx.url_name : this.mdxx.fx_title,
      path: '/ymq_canyino2o/pages/Liar/loginindex',
      success: function (t) {},
      fail: function (t) {}
    }
  },
  onShareTimeline: function () {
    return {
      title: '' == this.mdxx.fx_title ? this.mdxx.url_name : this.mdxx.fx_title,
      path: '/ymq_canyino2o/pages/Liar/loginindex',
      success: function (t) {},
      fail: function (t) {}
    }
  },
  methods: {
    onNavClick(index) {
      this.curIndex = index
    },
    onLoadClone3389: function (t) {
      var that = this
      that.setData({
        isxlsxz: true
      })
      app.globalData.setNavigationBarColor(this)
      app.globalData.appPageOnLoad(this)
      app.globalData.getUserInfo(function (s) {
        console.log(s)
        app.globalData.util.request({
          url: 'entry/wxapp/CouponSet',
          cachetime: '0',

          success: function (t) {
            that.setData({
              userinfo: s,
              CouponSet: t.data
            })
            var e = util.formatTime(new Date()).slice(11, 16)
            console.log(t.data, e)
            if (e >= t.data.time && e < t.data.time2) {
              console.log('hbtime')
              if ('1' == t.data.is_tjhb) {
                app.globalData.util.request({
                  url: 'entry/wxapp/TjCoupons',
                  cachetime: '0',

                  data: {
                    user_id: s.id
                  },

                  success: function (t) {
                    console.log(t.data, _typeof(t.data))
                    t.data
                    t.data
                    if ('object' == _typeof(t.data)) {
                      console.log(_typeof(t.data))
                      that.setData({
                        istjhb: true,
                        tjhbarr: t.data
                      })
                      that.refresh()
                    }
                  }
                })
              }
            } else {
              console.log('nothbtime')
            }
          }
        })
      })
      app.globalData.util.request({
        url: 'entry/wxapp/system',
        cachetime: '0',

        success: function (t) {
          console.log(t)
          var n = t.data
          qqmapsdk = new QQMapWX({
            key: t.data.map_key
          })
          uni.setNavigationBarTitle({
            title: '商家分类'
          })
          that.setData({
            mdxx: t.data
          })
          app.globalData.util.request({
            url: 'entry/wxapp/TypeAd',
            cachetime: '0',

            success: function (t) {
              console.log(t.data)
              var a = []
              if ('1' == n.fl_more) {
                for (var e = 0, s = t.data.length; e < s; e += 8) {
                  a.push(t.data.slice(e, e + 8))
                }
              }
              if ('2' == n.fl_more) {
                for (e = 0, s = t.data.length; e < s; e += 10) {
                  a.push(t.data.slice(e, e + 10))
                }
              }
              console.log(a)
              that.setData({
                navs: a
              })
            }
          })
          that.dwreLoad()
          uni.setStorageSync('bqxx', t.data)
        }
      })
      app.globalData.util.request({
        url: 'entry/wxapp/Llz',
        cachetime: '0',

        data: {
          type: '1,2'
        },

        success: function (t) {
          console.log(t)
          for (var a = [], e = [], s = 0; s < t.data.length; s++) {
            if (1 == t.data[s].type) {
              a.push(t.data[s])
            }
            if (2 == t.data[s].type) {
              e.push(t.data[s])
            }
          }
          that.setData({
            dbllz: a,
            zbllz: e
          })
        }
      })
      app.globalData.util.request({
        url: 'entry/wxapp/ZbOrder',
        cachetime: '0',

        success: function (t) {
          console.log(t.data)
          that.setData({
            ZbOrder: t.data
          })
        }
      })
      app.globalData.util.request({
        url: 'entry/wxapp/QgGoods',
        cachetime: '0',

        data: {
          type_id: '',
          store_id: '',
          page: 1,
          pagesize: 10,
          type: 1
        },

        success: function (t) {
          console.log('分页返回的列表数据', t.data)
          for (var a = 0; a < t.data.length; a++) {
            t.data[a].discount = (
              (Number(t.data[a].money) / Number(t.data[a].price)) *
              10
            ).toFixed(1)
            t.data[a].yqnum = (
              ((Number(t.data[a].number) - Number(t.data[a].surplus)) /
                Number(t.data[a].number)) *
              100
            ).toFixed(1)
          }
          that.setData({
            qglist: t.data
          })
        }
      })
      app.globalData.util.request({
        url: 'entry/wxapp/ad',
        cachetime: '0',

        success: function (t) {
          console.log(t)
          for (
            var a = [], e = [], s = [], n = [], i = 0;
            i < t.data.length;
            i++
          ) {
            if ('1' == t.data[i].type) {
              a.push(t.data[i])
            } else {
              if ('3' == t.data[i].type) {
                e.push(t.data[i])
              } else {
                if ('4' == t.data[i].type) {
                  s.push(t.data[i])
                } else {
                  if ('11' == t.data[i].type) {
                    n.push(t.data[i])
                  }
                }
              }
            }
          }
          that.setData({
            toplb: a,
            zblb: e,
            dblb: s,

            cardlist: {
              upDownPadding: 10,
              leftRightPadding: 15,
              numberOfRow: 2,
              pictureList: n,
              radius: 10,
              padding: 10,
              height: 190
            }
          })
        }
      })
    },

    refresh: function () {
      var that = this
      var t = uni.createAnimation({
        duration: 3000,
        timingFunction: 'linear'
      })
      t.opacity(0.2)
        .step({
          duration: 200
        })
        .opacity(0.3)
        .scale(1.1, 1.1)
        .translate3d(0, 10, 0)
        .step({
          duration: 200
        })
        .opacity(0.4)
        .scale(1.2, 1.2)
        .translate3d(0, 30, 0)
        .step({
          duration: 200
        })
        .opacity(0.5)
        .scale(1.3, 1.3)
        .translate3d(0, 50, 0)
        .step({
          duration: 200
        })
        .opacity(0.6)
        .scale(1.4, 1.4)
        .translate3d(0, 70, 0)
        .step({
          duration: 200
        })
        .opacity(0.7)
        .translate3d(0, 90, 0)
        .step({
          duration: 200
        })
        .opacity(0.8)
        .translate3d(0, 110, 0)
        .step({
          duration: 200
        })
        .opacity(0.9)
        .translate3d(0, 130, 0)
        .step({
          duration: 200
        })
        .opacity(1)
        .translate3d(0, 140, 0)
        .step({
          duration: 200
        })
      that.setData({
        animationData_4: t.export()
      })
      var e = uni.createAnimation({
        duration: 3000,
        timingFunction: 'linear'
      })
      e.opacity(0.2)
        .step({
          duration: 200
        })
        .opacity(0.3)
        .scale(1.1, 1.1)
        .translate3d(-10, 10, 0)
        .step({
          duration: 200
        })
        .opacity(0.4)
        .scale(1.2, 1.2)
        .translate3d(-15, 30, 0)
        .step({
          duration: 200
        })
        .opacity(0.5)
        .scale(1.3, 1.3)
        .translate3d(-20, 50, 0)
        .step({
          duration: 200
        })
        .opacity(0.6)
        .scale(1.4, 1.4)
        .translate3d(-25, 70, 0)
        .step({
          duration: 200
        })
        .opacity(0.7)
        .translate3d(-30, 90, 0)
        .step({
          duration: 200
        })
        .opacity(0.8)
        .translate3d(-35, 110, 0)
        .step({
          duration: 200
        })
        .opacity(0.9)
        .translate3d(-40, 130, 0)
        .step({
          duration: 200
        })
        .opacity(1)
        .translate3d(-30, 150, 0)
        .step({
          duration: 200
        })
      that.setData({
        animationData_5: e.export()
      })
      var s = uni.createAnimation({
        duration: 3000,
        timingFunction: 'linear'
      })
      s.translate3d(0, 0, 0)
        .scale(0, 0)
        .translate3d(0, 0, 0)
        .step({
          duration: 200
        })
        .scale(0.2, 0.2)
        .translate3d(0, 20, 0)
        .step({
          duration: 200
        })
        .scale(0.4, 0.4)
        .translate3d(0, 40, 0)
        .step({
          duration: 200
        })
        .scale(0.6, 0.6)
        .translate3d(0, 60, 0)
        .step({
          duration: 200
        })
        .scale(0.8, 0.8)
        .translate3d(0, 80, 0)
        .step({
          duration: 200
        })
        .scale(1, 1)
        .translate3d(0, 90, 0)
        .step({
          duration: 200
        })
      that.setData({
        animationData: s.export()
      })
      var n = uni.createAnimation({
        duration: 3000,
        timingFunction: 'linear'
      })
      n.scale(0, 0)
        .step({
          duration: 100
        })
        .scale(0.2, 0.2)
        .step({
          duration: 100
        })
        .scale(0.4, 0.4)
        .step({
          duration: 100
        })
        .scale(0.6, 0.6)
        .step({
          duration: 200
        })
        .scale(0.8, 0.8)
        .step({
          duration: 200
        })
        .scale(1, 1)
        .step({
          duration: 200
        })
      that.setData({
        animationData_1: n.export()
      })
      setTimeout(function () {
        console.log('开始执行')
        var t = uni.createAnimation({
          duration: 3000,
          timingFunction: 'linear'
        })
        t.opacity(0.1)
          .step({
            duration: 100
          })
          .opacity(0.3)
          .scale(1.1, 1.1)
          .translate3d(10, 10, 0)
          .step({
            duration: 100
          })
          .opacity(0.4)
          .scale(1.2, 1.2)
          .translate3d(11, 15, 0)
          .step({
            duration: 100
          })
          .opacity(0.5)
          .scale(1.3, 1.3)
          .translate3d(12, 20, 0)
          .step({
            duration: 100
          })
          .opacity(0.6)
          .scale(1.4, 1.4)
          .translate3d(13, 25, 0)
          .step({
            duration: 100
          })
          .opacity(0.7)
          .translate3d(14, 30, 0)
          .step({
            duration: 100
          })
          .opacity(0.8)
          .translate3d(15, 35, 0)
          .step({
            duration: 100
          })
          .opacity(0.9)
          .translate3d(16, 40, 0)
          .step({
            duration: 100
          })
          .opacity(1)
          .translate3d(17, 45, 0)
          .step({
            duration: 100
          })
        that.setData({
          animationData_2: t.export()
        })
      }, 700)
      setTimeout(function () {
        var t = uni.createAnimation({
          duration: 3000,
          timingFunction: 'linear'
        })
        t.opacity(0.1)
          .step({
            duration: 100
          })
          .opacity(0.3)
          .scale(1.1, 1.1)
          .translate3d(-100, 10, 0)
          .step({
            duration: 70
          })
          .opacity(0.4)
          .scale(1.2, 1.2)
          .translate3d(-110, 15, 0)
          .step({
            duration: 70
          })
          .opacity(0.5)
          .scale(1.3, 1.3)
          .translate3d(-120, 20, 0)
          .step({
            duration: 70
          })
          .opacity(0.6)
          .scale(1.4, 1.4)
          .translate3d(-130, 25, 0)
          .step({
            duration: 100
          })
          .opacity(0.7)
          .translate3d(-120, 30, 0)
          .step({
            duration: 130
          })
          .opacity(0.8)
          .translate3d(-110, 35, 0)
          .step({
            duration: 130
          })
          .opacity(0.9)
          .translate3d(-100, 40, 0)
          .step({
            duration: 130
          })
          .opacity(1)
          .translate3d(-90, 45, 0)
          .step({
            duration: 130
          })
        that.setData({
          animationData_6: t.export()
        })
      }, 700)
      setTimeout(function () {
        var t = uni.createAnimation({
          duration: 3000,
          timingFunction: 'linear'
        })
        t.opacity(0.1)
          .translate3d(0, 0, 0)
          .step({
            duration: 100
          })
          .opacity(0.3)
          .scale(1.1, 1.1)
          .translate3d(10, 10, 0)
          .step({
            duration: 70
          })
          .opacity(0.4)
          .scale(1.2, 1.2)
          .translate3d(20, 15, 0)
          .step({
            duration: 70
          })
          .opacity(0.5)
          .scale(1.3, 1.3)
          .translate3d(30, 20, 0)
          .step({
            duration: 70
          })
          .opacity(0.6)
          .scale(1.4, 1.4)
          .translate3d(40, 25, 0)
          .step({
            duration: 100
          })
          .opacity(0.7)
          .translate3d(50, 30, 0)
          .step({
            duration: 200
          })
          .opacity(0.8)
          .translate3d(60, 35, 0)
          .step({
            duration: 200
          })
          .opacity(0.9)
          .translate3d(70, 40, 0)
          .step({
            duration: 200
          })
          .opacity(1)
          .translate3d(80, 45, 0)
          .step({
            duration: 300
          })
        that.setData({
          animationData_7: t.export()
        })
      }, 700)
      setTimeout(function () {
        var t = uni.createAnimation({
          duration: 3000,
          timingFunction: 'ease-in-out'
        })
        t.opacity(0.1)
          .translate3d(20, -50, 0)
          .step({
            duration: 300
          })
          .opacity(1)
          .translate3d(40, 240, 200)
          .step({
            duration: 3000
          })
        that.setData({
          animationData_8: t.export()
        })
      }, 300)
      setTimeout(function () {
        setInterval(function () {
          var t = uni.createAnimation({
            duration: 3000,
            timingFunction: 'linear'
          })
          t.scale(1, 1)
            .step({
              duration: 300
            })
            .scale(1.1, 1.1)
            .step({
              duration: 300
            })
          that.setData({
            animationData_9: t.export()
          })
        }, 600)
      }, 1200)
    },

    onTapTag: function (t) {
      var a = this.params
      if ('1' == t.currentTarget.dataset.index) {
        a.by = 'juli asc'
      }
      if ('2' == t.currentTarget.dataset.index) {
        a.by = 'sales desc'
      }
      console.log(a, t.currentTarget.dataset.index)
      this.setData({
        sortSelected: this.sortList[0].sort,
        selected: t.currentTarget.dataset.index,
        params: a,
        pagenum: 1,
        storelist: [],
        bfstorelist: [],
        mygd: false,
        jzgd: true,
        mask1Hidden: true,
        mask2Hidden: true
      })
      this.getstorelist()
    },

    onSortSelectedFun: function (t) {
      var a = this.params
      console.log(t, 'ttttttt')
      if ('0' == t.currentTarget.dataset.sortindex) {
        a.by = 'number asc'
      }
      if ('1' == t.currentTarget.dataset.sortindex) {
        a.by = 'score desc'
      }
      if ('2' == t.currentTarget.dataset.sortindex) {
        a.by = 'start_at asc'
      }
      if ('3' == t.currentTarget.dataset.sortindex) {
        a.by = 'ps_money asc'
      }
      console.log(
        a,
        t.currentTarget.dataset.index,
        t.currentTarget.dataset.sortindex + 1
      )
      this.setData({
        selected: t.currentTarget.dataset.index,
        sortSelected: this.sortList[t.currentTarget.dataset.sortindex].sort,
        params: a,
        pagenum: 1,
        storelist: [],
        bfstorelist: [],
        mygd: false,
        jzgd: true
      })
      this.getstorelist()
    },

    finish: function () {
      var t = this.params
      var a = this.characteristicSelected
      var e = this.characteristicList
      var s = this.discountSelected
      this.setData({
        issx: true
      })
      for (var n = 0; n < a.length; n++) {
        if (a[n]) {
          if ('0配送费' == e[n].text) {
            t.nopsf = 1
          }
          if ('0元起送' == e[n].text) {
            t.nostart = 1
          }
        }
      }
      if (null != s) {
        t.yhhd = this.discountList[s].zdname
      } else {
        t.yhhd = ''
      }
      this.setData({
        params: t,
        pagenum: 1,
        storelist: [],
        bfstorelist: [],
        mygd: false,
        jzgd: true
      })
      this.getstorelist()
      console.log(t, this.issx, a, e, s)
    },

    clearSelectedNumb: function () {
      var t = this.params
      t.nopsf = 2
      t.nostart = 2
      t.yhhd = ''
      this.setData({
        characteristicSelected: [false],
        discountSelected: null,
        selectedNumb: 0,
        issx: false,
        params: t,
        pagenum: 1,
        storelist: [],
        bfstorelist: [],
        mygd: false,
        jzgd: true
      })
      this.getstorelist()
    },

    characteristicSelectedFun: function (t) {
      var a = this.characteristicSelected
      a[t.currentTarget.dataset.index] = !a[t.currentTarget.dataset.index]
      this.setData({
        characteristicSelected: a,
        selectedNumb:
          this.selectedNumb + (a[t.currentTarget.dataset.index] ? 1 : -1)
      })
      console.log(
        a,
        t.currentTarget.dataset.index,
        t.currentTarget.dataset.name
      )
    },

    discountSelectedFun: function (t) {
      if (this.discountSelected != t.currentTarget.dataset.index) {
        this.setData({
          discountSelected: t.currentTarget.dataset.index,
          selectedNumb:
            this.selectedNumb + (null == this.discountSelected ? 1 : 0)
        })
      } else {
        this.setData({
          discountSelected: null,
          selectedNumb: this.selectedNumb - 1
        })
      }
    },

    mask1Cancel: function () {
      this.setData({
        mask1Hidden: !this.mask1Hidden
      })
    },

    mask2Cancel: function () {
      this.setData({
        mask2Hidden: true
      })
    },

    onOverallTag: function (t) {
      console.log(t)
      this.setData({
        mask1Hidden: false,
        mask2Hidden: true
      })
    },

    onFilter: function () {
      this.setData({
        mask2Hidden: false,
        mask1Hidden: true
      })
    },

    hddb: function () {
      uni.pageScrollTo({
        scrollTop: 0,
        duration: 1000
      })
    },

    dwreLoad: function () {
      var that = this
      var i = this.params
      uni.getLocation({
        type: 'wgs84',
        success: function (t) {
          var e = t.latitude
          var s = t.longitude
          i.lat = e
          i.lng = s
          that.setData({
            params: i
          })
          that.getstorelist()
          app.globalData.util.request({
            url: 'entry/wxapp/Brand',
            cachetime: '0',
            data: {
              lat: e,
              lng: s
            },
            success: function (t) {
              that.setData({
                Brand: t.data
              })
            }
          })
          qqmapsdk.reverseGeocoder({
            location: {
              latitude: e,
              longitude: s
            },
            coord_type: 1,
            success: function (t) {
              var a = t.result.ad_info.location
              that.setData({
                weizhi: t.result.formatted_addresses.recommend,
                startjwd: a
              })
            },
            fail: function (t) {
              console.log(t)
            },
            complete: function (t) {
              console.log(t)
            }
          })
        },
        fail: function () {
          uni.getSetting({
            success: function (t) {
              console.log(t)
              if (0 == t.authSetting['scope.userLocation']) {
                uni.showModal({
                  title: '提示',
                  content:
                    '您点击了拒绝授权,无法正常使用功能，点击确定重新获取授权。',
                  showCancel: false,
                  success: function (t) {
                    if (t.confirm) {
                      console.log('用户点击确定')
                      uni.openSetting({
                        success: function (t) {
                          t.authSetting['scope.userLocation']
                          that.dwreLoad()
                        }
                      })
                    }
                  }
                })
              }
            }
          })
        },
        complete: function (t) {}
      })
    },

    getstorelist: function () {
      var that = this
      var l = that.pagenum
      that.params.page = l
      that.params.pagesize = 10
      console.log(l, that.params)
      that.setData({
        isjzz: true
      })
      app.globalData.util.request({
        url: 'entry/wxapp/StoreList',
        cachetime: '0',
        data: that.params,
        success: function (t) {
          if (t.data.length < 10) {
            that.setData({
              mygd: true,
              jzgd: true,
              isjzz: false
            })
          } else {
            that.setData({
              jzgd: true,
              pagenum: l + 1,
              isjzz: false
            })
          }
          for (var a = 0, e = t.data.length; a < e; a++) {
            if ('0.0' == t.data[a].sales) {
              t.data[a].sales = '5.0'
            }
            var s = parseFloat(t.data[a].juli)
            if (s < 1000) {
              t.data[a].aa = s + 'm'
            } else {
              t.data[a].aa = (s / 1000).toFixed(2) + 'km'
            }
            t.data[a].aa1 = s
          }
          var n = that.bfstorelist
          n = n.concat(t.data)
          if (1 == that.mdxx.isyykg) {
            for (var i = [], o = [], r = 0, d = n.length; r < d; r++) {
              if (2 == n[r].is_yy) {
                o.push(n[r])
              } else {
                i.push(n[r])
              }
            }
            n = i.concat(o)
          }
          n = (function (t) {
            for (var a = [], e = 0, s = t.length; e < s; e++) {
              if (-1 == a.indexOf(t[e])) {
                a.push(t[e])
              }
            }
            return a
          })(n)
          that.setData({
            isxlsxz: false,
            storelist: n,
            bfstorelist: n
          })
        }
      })
    },

    jumps: function (t) {
      var a = t.currentTarget.dataset.id
      var e = t.currentTarget.dataset.name
      var s = t.currentTarget.dataset.appid
      var n = t.currentTarget.dataset.src
      var i = t.currentTarget.dataset.wb_src
      var o = t.currentTarget.dataset.type
      console.log(a, e, s, n, i, o)
      if (1 == o) {
        console.log(n)
        uni.navigateTo({
          url: n
        })
      } else {
        if (2 == o) {
          uni.setStorageSync('vr', i)
          uni.navigateTo({
            url: '../car/car'
          })
        } else {
          if (3 == o) {
            uni.navigateToMiniProgram({
              appId: s
            })
          }
        }
      }
    },

    tzsjxq: function (t) {
      console.log(t.currentTarget.dataset, this.mdxx)
      if (1 == t.currentTarget.dataset.type) {
        getApp().globalData.sjid = t.currentTarget.dataset.sjid
        uni.navigateTo({
          url: '/ymq_canyino2o/pages/seller/index'
        })
      } else {
        if ('1' == this.mdxx.is_tzms) {
          getApp().globalData.sjid = t.currentTarget.dataset.sjid
          uni.navigateTo({
            url: '/ymq_canyino2o/pages/seller/index'
          })
        } else {
          uni.navigateTo({
            url:
              '/ymq_canyino2o/pages/takeout/takeoutindex?storeid=' +
              t.currentTarget.dataset.sjid
          })
        }
      }
    },

    qxd: function () {
      this.setData({
        istjhb: false
      })
    },

    sssj: function () {
      uni.navigateTo({
        url: 'sssj'
      })
    },

    xzwz() {
      console.log('占位：函数 xzwz 未声明')
    },

    tzweb() {
      console.log('占位：函数 tzweb 未声明')
    }
  }
}
</script>
<style>
@import './index.css';
</style>
<style scoped>
.nav {
  width: 80%;
  margin: 20rpx auto;
  display: flex;
  justify-content: space-between;
}
.nav .nav-item {
  padding: 10rpx 0;
}
.nav .nav-item.active {
  position: relative;
  background: none !important;
  width: auto !important;
  color: #34aaff;
}
.nav .nav-item.active::after {
  content: ' ';
  display: block;
  position: absolute;
  width: 100%;
  height: 6rpx;
  background: #34aaff;
  bottom: -10rpx;
  left: 0;
}
</style>
